package cn.momoshenchi.medicine.pojo;

import cn.momoshenchi.medicine.enumerate.Add;
import cn.momoshenchi.medicine.enumerate.Update;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;

/**
 * 药品频次表
 * @TableName base_dic_drug_frequency
 */
@TableName(value ="base_dic_drug_frequency")
public class BaseDicDrugFrequency implements Serializable {
    /**
     * 项目代码
     */
    @TableId(type = IdType.AUTO)
    @Null(groups = Add.class)
    @NotNull(groups = Update.class)
    private Integer itemCode;

    /**
     * 项目名称
     */
    @NotBlank(message = "项目名称不能为空",groups = Add.class)
    private String itemName;

    /**
     * 项目名称缩写
     */
    @NotBlank(message = "项目名称缩写不能为空",groups = Add.class)
    private String itemNameAbbr;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * 项目代码
     */
    public Integer getItemCode() {
        return itemCode;
    }

    /**
     * 项目代码
     */
    public void setItemCode(Integer itemCode) {
        this.itemCode = itemCode;
    }

    /**
     * 项目名称
     */
    public String getItemName() {
        return itemName;
    }

    /**
     * 项目名称
     */
    public void setItemName(String itemName) {
        this.itemName = itemName;
    }

    /**
     * 项目名称缩写
     */
    public String getItemNameAbbr() {
        return itemNameAbbr;
    }

    /**
     * 项目名称缩写
     */
    public void setItemNameAbbr(String itemNameAbbr) {
        this.itemNameAbbr = itemNameAbbr;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        BaseDicDrugFrequency other = (BaseDicDrugFrequency) that;
        return (this.getItemCode() == null ? other.getItemCode() == null : this.getItemCode().equals(other.getItemCode()))
            && (this.getItemName() == null ? other.getItemName() == null : this.getItemName().equals(other.getItemName()))
            && (this.getItemNameAbbr() == null ? other.getItemNameAbbr() == null : this.getItemNameAbbr().equals(other.getItemNameAbbr()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getItemCode() == null) ? 0 : getItemCode().hashCode());
        result = prime * result + ((getItemName() == null) ? 0 : getItemName().hashCode());
        result = prime * result + ((getItemNameAbbr() == null) ? 0 : getItemNameAbbr().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", itemCode=").append(itemCode);
        sb.append(", itemName=").append(itemName);
        sb.append(", itemNameAbbr=").append(itemNameAbbr);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}